\subsection{Policy Representation Layer}
\label{sec:representation} 

The policy representation layer consists of a recursive algorithm that processes Java objects and method calls in order to represent them using the facts described in Figure~\ref{fig:state}. For example, consider an instance of the declared class \textsf{doctor} with a field \texttt{age} of type \texttt{Integer} and another field \texttt{patients} of type \texttt{ArrayList} of \texttt{Patient}. Class \texttt{Patient} has a single field \texttt{name} of type \texttt{String}. Suppose there are two patients $\mathsf{P_1}$ and $\mathsf{P_2}$ in the treated patients list of doctor \textsf{X}. These objects would be represented as follows:

\begin{itemize}
\item \textsf{instance\_of(X,doctor)} representing the instance,
\item \textsf{field\_of(X,age,18)} if the value of \texttt{age} of \texttt{X} is 18,
\item \textsf{field\_of(X,patients,Y)} where $Y$ is an identifier of the \texttt{ArrayList} of \texttt{patients},
\item \textsf{field\_of(Y,e,P$_1$)} where $\mathsf{P_1}$ is an identifier of the first \texttt{Patient}, this fact denotes that $\mathsf{P_1}$ is an element of the \texttt{ArrayList} of \texttt{patients},
\item \textsf{field\_of(Y,e,P$_2$)} where $\mathsf{P_2}$ is an identifier of the second \texttt{Patient},
\item \textsf{field\_of(P$_1$,name,'John')} if the name of the first \texttt{Patient} is \texttt{John},
\item \textsf{field\_of(P$_2$,name,'Ben')} if the name of the second \texttt{Patient} is \texttt{Ben}.
\end{itemize}
\noindent A method call is represented using a fact of the form \texttt{call\_of(method\_id)} where \texttt{method\_id} is the method alias. Methods are processed similarly to class instances. However, $\mathsf{param\_of}$ facts use the parameter position instead of attribute names: for example, a fact \textsf{param\_of(delete\_method,1,X)} means that $X$ is the first parameter of the method call \textsf{delete\_method}. Method calls have two additional parameters, namely the \textsf{this} and \textsf{target} parameters denoting the calling and called instances of the method call respectively. AspectJ enables an easy identification of these instances for intercepted method calls.

